﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

using System.Web.Security;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace HZ.Supervise.Web.Secondphase
{
    public partial class ComplainReply : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindData();
        }
        void BindData()
        {
            if (Request.QueryString["id"] != null)
            {
                int t = 0;
                HZ.Supervise.IBLL.IBLL_PreWarning pre = HZ.Supervise.BLLFactory.IBLL_PreWarning();
                System.Data.DataTable dt = new System.Data.DataTable();
                HZ.Supervise.Model.Complain complain = new HZ.Supervise.Model.Complain();
                //complain.ComplainTime = HZ.Fun.CheckString(this.txtComPlainDate.Text);
                complain.ComplainID = Request.QueryString["id"].ToString();
                complain.ComplainTime = "1900-2-2";
                complain.ReplyTime = "1900-2-2";
                complain.Status = 3;
                dt = pre.GetComplain(complain, 0, 12, out t);

                lblTopic.Text = dt.Rows[0]["Title"].ToString();
                lblComplainTo.Text = dt.Rows[0]["ComplainTo"].ToString();
                lblComplainContent.Text = dt.Rows[0]["Content"].ToString() ;
            }
            
        }
        /// <summary>
        /// 对此投诉进行回复
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnReply_Click(object sender, EventArgs e)
        {
            HZ.Supervise.IBLL.IBLL_PreWarning pre = HZ.Supervise.BLLFactory.IBLL_PreWarning();
            HZ.Supervise.Model.Complain complain = new HZ.Supervise.Model.Complain();
            complain.ReplyTime = DateTime.Now.ToShortDateString();
            complain.ReplyContent = txtReplyContent.Value.ToString();
            complain.ComplainID = Request.QueryString["id"].ToString();
            complain.Status = 1;

            if (pre.ReplyComplain(complain)>0)
            {
                //HZ.Web.WebHint.ShowInfo("回复成功！", "AduitCompany.aspx");
                HZ.Web.WebUtil.Alert("回复成功！");
            }
            else
            {
                HZ.Web.WebUtil.Alert("回复失败",this);
            }
            Response.Redirect("ComplainList.aspx");
        }

        protected void btnExit_Click(object sender, EventArgs e)
        {
            Response.Redirect("ComplainList.aspx");
        }
    }
}
